home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 68.7z
/
BS1 part 68
/
InterChange Plus v3.0 (1993-11)(Syndesis)(Disk 2 of 2).7z
/
InterChange Plus v3.0 (1993-11)(Syndesis)(Disk 2 of 2).adf
/
PC_Tools.LZH
/
ALISP.ZIP
/
EXBLOCK.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1993-10-06
|
12KB
|
313 lines
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ ³
³ EXBLOCK.LSP ³
³ ³
³ Don Brown Version 0.9 7/24/90 ³
³ ³
³ "EX" - Explodes unequal X/Y/Z scale blocks. ³
³ ³
³ Erases the selected block. It then procedes to recreate the block from ³
³ scratch. It does this by looking in the TABLES for the block, then goes ³
³ through each entity, one by one. ³
³ ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Main Routine ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun c:ex (/ osmode fltlnd cmdeko ent ent-gt)
(setq osmode (getvar "osmode")
fltlnd (getvar "flatland")
cmdeko (getvar "cmdecho"))
(setvar "osmode" 0)
(setvar "flatland" 0)
(setvar "cmdecho" 0)
(setq ent (entsel))
(if ent (progn
(setq ent-gt (entget (car ent)))
(if (= "INSERT" (~fld 0 ent-gt))
(~doit ent-gt)
(princ "\n\7Entity isn't a block!")
)
))
(setvar "osmode" osmode)
(setvar "flatland" fltlnd)
(setvar "cmdecho" cmdeko)
(princ)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Dxf Extractor ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~fld (num temp) (cdr (assoc num temp)))
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Radians to Degrees converter ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~rtd (temp) (* 180.0 (/ temp pi)))
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Midpoint of 2 points ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~mid (A B) (mapcar '(lambda (I J) (/ (+ I J) 2)) A B))
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Converts old point to new point ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~newpt (old-pt / newpt dist angl)
(setq newpt (list
(* (car old-pt) x-scal)
(* (cadr old-pt) y-scal)
(* (caddr old-pt) z-scal)
)
dist (distance blkins newpt)
angl (angle blkins newpt)
)
(polar ins-pt (+ rot-an angl) dist)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Sets the Linetype, Elevation Thickness & Color ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~sets (entity)
(command "linetype" "s"
(if (~fld 6 entity) (~fld 6 entity) "bylayer")
"")
(command "elev" (if (~fld 38 entity) (* elevat (~fld 38 entity)) 0.0)
(if (~fld 39 entity) (* thick (~fld 39 entity)) 0.0))
(command "color" (if (~fld 62 entity) (~fld 62 entity) "bylayer"))
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ This part does all the work ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~doit (entity)
(princ "\nOk...It's a block!\n\n")
; Remove the following semi-colon to erase original block
; (command ".erase" (~fld -1 entity) "")
(setq bl-nam (~fld 2 entity) ;\
elevat (~fld 38 entity) ; \
thick (~fld 39 entity) ; \
ins-pt (~fld 10 entity) ; \ Entity's sets
rot-an (~fld 50 entity) ; /
x-scal (~fld 41 entity) ; /
y-scal (~fld 42 entity) ; /
z-scal (~fld 43 entity) ;/
)
(if (null thick) (setq thick 0.0))
(if (null elevat) (setq elevat 0.0))
(setq bl-def (tblsearch "BLOCK" bl-nam)
nxtent (~fld -2 bl-def) ;first entity
blkins (~fld 10 bl-def)
)
(while nxtent
(setq nxtget (entget nxtent)
enttyp (~fld 0 nxtget)
)
(~sets nxtget)
(cond
((= enttyp "3DFACE") (princ "\n3DFACE") (~3dface))
((= enttyp "3DLINE") (princ "\n3DLINE") (~point))
((= enttyp "ARC") (princ "\nARC") (~arc))
((= enttyp "ATTDEF") (princ "\nATTDEF") (princ "...Not supported (yet)"))
((= enttyp "ATTRIB") (princ "\nATTRIB") (princ "...Not supported (yet)"))
((= enttyp "CIRCLE") (princ "\nCIRCLE")
(command ".ellipse" "C"
(~newpt (~fld 10 nxtget))
(~newpt (polar (~fld 10 nxtget) 0 (~fld 40 nxtget)))
(~newpt (polar (~fld 10 nxtget) (/ pi 2.0) (~fld 40 nxtget)))
))
((= enttyp "DIMENSION") (princ "\nDIMENSION") (~dimen))
((= enttyp "INSERT") (princ "\nINSERT") (~insrt))
((= enttyp "LINE") (princ "\nLINE") (~point))
((= enttyp "POINT") (princ "\nPOINT") (~point))
((= enttyp "POLYLINE") (princ "\nPOLYLINE") (~pline))
((= enttyp "SHAPE") (princ "\nSHAPE")
(command ".shape"
(~fld 2 nxtget)
(~newpt (~fld 10 nxtget))
(* x-scal (~fld 40 nxtget))
(~rtd (+ rot-an (~fld 50 nxtget)))
)
)
((= enttyp "SOLID") (princ "\nSOLID") (~point))
((= enttyp "TEXT") (princ "\nTEXT") ;(~text)
)
((= enttyp "TRACE") (princ "\nTRACE")
(command ".TRACE"
(distance (~newpt (~fld 10 nxtget))
(~newpt (~fld 11 nxtget)))
(~mid (~newpt (~fld 10 nxtget))
(~newpt (~fld 11 nxtget)))
(~mid (~newpt (~fld 12 nxtget))
(~newpt (~fld 13 nxtget)))
""
)
)
((= enttyp "VERTEX") (princ "\nVERTEX") (~vertex))
(T
(princ enttyp)
(princ "\n")
(princ nxtget)
) ;end T
)
(setq nxtent (entnext nxtent))
)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 3D FACES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~3dface ( / face face-1 face-2 face-3 face-4)
(command ".3dface")
(setq face (~fld 70 nxtget)
face-4 (if (>= face 8) (progn (setq face (- face 8)) T) nil)
face-3 (if (>= face 4) (progn (setq face (- face 4)) T) nil)
face-2 (if (>= face 2) (progn (setq face (- face 2)) T) nil)
face-1 (if (>= face 1) (progn (setq face (- face 1)) T) nil)
)
(if face-1 (command "i"))
(command (~newpt (~fld 10 nxtget)))
(if face-2 (command "i"))
(command (~newpt (~fld 11 nxtget)))
(if face-3 (command "i"))
(command (~newpt (~fld 12 nxtget)))
(if face-4 (command "i"))
(command (~newpt (~fld 13 nxtget)) "")
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ARC ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~arc ( / p1 p2)
(command ".ellipse" "C"
(~newpt (~fld 10 nxtget))
(~newpt (polar (~fld 10 nxtget) 0 (~fld 40 nxtget)))
(~newpt (polar (~fld 10 nxtget) (/ pi 2.0) (~fld 40 nxtget)))
)
(setq ell (entlast))
(command
".line"
(setq p1 (~newpt (polar (~fld 10 nxtget) (~fld 51 nxtget) (~fld 40 nxtget))))
(setq p2 (~newpt (polar (~fld 10 nxtget) (~fld 50 nxtget) (~fld 40 nxtget))))
""
".change" (entlast) "" (polar p1 (angle p2 p1) 5)
".change" (entlast) "" (polar p2 (angle p1 p2) 5)
)
(setq line (entlast)
p1 (~fld 50 nxtget)
p2 (~fld 51 nxtget))
(command
".trim" line ""
(list ell
(~newpt
(polar
(~fld 10 nxtget)
(+ rot-an pi
(/ (+ p1 p2
(if (> p1 p2)
(* pi 2.0)
0.0
) ;enf if
) ;end +
2.0
) ;end /
) ;end +
(~fld 40 nxtget)
) ;end polar
) ;end ~newpt
) ;end list
""
) ;end command
(entdel line)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Dimension ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~dimen (/ kind)
(princ nxtget)
(setq kind (~fld 70 nxtget))
(command ".dim" "rot"
(cond
((= kind 0) "rotated"
(~rtd (+ rot-an (~fld 50 nxtget)))
)
((= kind 1) "aligned")
((= kind 2) "angular")
((= kind 3) "diameter")
((= kind 4) "radius")
)
(~newpt (~fld 10 nxtget))
(~newpt (~fld 13 nxtget))
(~newpt (~fld 11 nxtget))
(if (~fld 1 nxtget) (~fld 1 nxtget) "")
"exit")
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ INSERT ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~insrt ()
(command ".insert"
(~fld 2 nxtget)
(~newpt (~fld 10 nxtget))
"XYZ"
(* x-scal (~fld 41 nxtget))
(* y-scal (~fld 42 nxtget))
(* z-scal (~fld 43 nxtget))
(~rtd (+ rot-an (~fld 50 nxtget)))
)
(if (~fld 66 nxtget)
(princ "...Attributes of blocks not supported (yet).")
)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ POINTS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~point ()
(command (strcat "." (~fld 0 nxtget)))
(if (~fld 10 nxtget) (command (~newpt (~fld 10 nxtget))))
(if (~fld 11 nxtget) (command (~newpt (~fld 11 nxtget))))
(if (~fld 12 nxtget) (command (~newpt (~fld 12 nxtget))))
(if (~fld 13 nxtget) (command (~newpt (~fld 13 nxtget))))
(command)
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~text (/ height angl)
(getstring)
(setvar "cmdecho" 1)
(setq height (* y-scal (~fld 40 nxtget))
angl (~rtd (+ rot-an (~fld 50 nxtget))))
(Command ".text" "s" (~fld 7 nxtget))
(mem)
(cond
((= (~fld 72 nxtget) 0)
(command (~newpt (~fld 10 nxtget))
height angl)
)
((= (~fld 72 nxtget) 1)
(command "C" (~newpt (~fld 10 nxtget))
height angl)
)
((= (~fld 72 nxtget) 2)
(command "R" (~newpt (~fld 10 nxtget))
height angl)
)
((= (~fld 72 nxtget) 3)
(command "A" (~newpt (~fld 10 nxtget))
(~newpt (~fld 11 nxtget)))
)
((= (~fld 72 nxtget) 4)
(command "M" (~newpt (~fld 10 nxtget))
height angl)
)
((= (~fld 72 nxtget) 5)
(command "F" (~newpt (~fld 10 nxtget))
(~newpt (~fld 11 nxtget))
height angl)
)
) ;end cond
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Pline ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(Defun ~pline ()
(setq p-type (~fld 70 nxtget)
pmeshm (~fld 71 nxtget)
pmeshn (~fld 72 nxtget)
smeshn (~fld 73 nxtget)
smeshn (~fld 74 nxtget)
swidth (~fld 41 nxtget)
ewidth (~fld 42 nxtget)
smooth (~fld 75 nxtget)
)
(if (>= p-type 32) (Setq closen T p-type (- p-type 32)) (setq closen nil))
(if (>= p-type 16) (Setq pmesh T p-type (- p-type 16)) (setq pmesh nil))
(if (>= p-type 8) (Setq pline T p-type (- p-type 8)) (setq pline nil))
(if (>= p-type 4) (Setq spline T p-type (- p-type 4)) (setq spline nil))
(if (>= p-type 2) (Setq curve T p-type (- p-type 2)) (setq curve nil))
(if (>= p-type 1) (Setq closem T p-type (- p-type 1)) (setq closem nil))
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(defun ~vertex ()
(princ "\tStill under production...")
)
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
(princ "loaded.")
(trace ~text)
(C:ex)